// ignore_for_file: unused_local_variable

import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_app/main02.dart';
import 'package:flutter_app/main26.dart';
import 'res/listData.dart';
import 'pages/Tabs.dart';
import 'routes/routes.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Flutter_Demo"),
        ),
        body: HomePage(),
      ),
    );
  }
}

//自定义有状态组件
class HomePage extends StatefulWidget {
  HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List list = [];
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        Column(
          children: this.list.map((e) {
            return ListTile(
              title: e,
            );
          }).toList(),
        ),
        SizedBox(
          height: 20,
        ),
        ElevatedButton(
            onPressed: () {
              setState(() {
                list.add(ListTile(
                  title: Text("你好，我是第${this.list.length}新闻"),
                ));
              });
            },
            child: Text("按钮"))
      ],
    );
  }
}
